var $myTable;
jQuery(function($) {
	"use strict";
	//构建分页查询表格
	var $columns = [
        {radio: true},
        {title: '任务ID', field: 'taskId'},
        {title: '任务名称', field: 'taskName'},
        {title: '任务类型', field: 'taskType'},
        {title: '操作类型', field: 'operType'},
        {title: '操作人员名称', field: 'operatorName'},
        {title: '创建时间', field: 'createDate'},
        {title: '开始时间', field: 'beginTime'},
        {title: '完成时间', field: 'finishTime'},
        {title: '消耗时间', field: 'costTime'},
        {title: '处理状态', field: 'procStateDesc'},
        {title: '处理方式', field: 'procWay'
        	,formatter: function(value, row, index) {
        		if(value == 'F') return '实时';
        		return '后台';
        	}
        },
        {title: '总数', field: 'totalRec'},
        {title: '成功数量', field: 'succRec'},
        {title: '失败数量', field: 'failRec'},
        //{title: '失败日志', field: 'failLog'},
        //{title: '处理文件', field: 'proceFileName'},
        {title: '服务器IP', field: 'serverIP'}
    ];
	var tc_height = $(window).height() -$('#myQueryForm').outerHeight(true)-$('#myToolbar').outerHeight(true)-5;
	$myTable = mvc.bootstrap.pageTable({
			url: resources['query'],//查询接口
			queryForm : '#myQueryForm',//查询条件录入
			table: '#myTable',//展示列表
			toolbar: "#myToolbar",//按钮区域
			height: tc_height,
			columns: $columns,
			detailView: true
		})
	
	//导出按钮
	$('#exportBtn').click(function(){
		document.getElementById('myQueryForm').action = resources['export'];
		document.getElementById('myQueryForm').submit();
	});
	//下载失败文件
	$('#downErrorBtn').click(function(){
		var checkeds = $myTable.bootstrapTable('getSelections');
		if(checkeds.length === 1){
			open(resources['downError']+checkeds[0].taskId);
		}
	});
});